<?php
/**
 * tx009 网站文章发布系统
 */
//**** 初始化一些目录信息 ****//

    
define('ROOT_PATH', dirname(__FILE__) . '/');
define('LIB_PATH', ROOT_PATH . 'lib/');
define('IMG_PATH', ROOT_PATH . 'img/');
    
require_once ROOT_PATH . 'config.php';  // 导入配置文件
    
login($sessions);

function login($sessions){
    
    $time = date('m-d',time());
    
    print_r("======天下网用户登录系统======\n启动时间: " . date('Y-m-d H:i:s') . "\n\n");
    // 初始化
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 65);
    
    foreach($sessions as $session ){
        
    //==========================================初始化用户信息======================================
        print_r("当前用户:".$session['id']."\n\n");
        
        $cookieVerify = "PHPSESSID=".$session['id'];
        curl_setopt($ch, CURLOPT_COOKIE, $cookieVerify);
        
        
        curl_setopt($ch, CURLOPT_URL, "http://www.tx009.com/center/index");
        $result = curl_exec($ch);
        
        $result = str_replace(array("\r\n", "\r", "\n"), "",$result);
        
        preg_match('/请先登录/',$result,$error);
        
        if(!empty($error)){
            print_r($session['qq']." session失效\n");
        }
    }
    print_r("======天下网用户登录系统======\n完毕时间: " . date('Y-m-d H:i:s') . "\n\n");
}